package com.ld.hpfs.service.impl;

import java.util.ArrayList;
import java.util.HashMap;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.ld.hpfs.dao.PlanMapper;
import com.ld.hpfs.service.PlanService;

@Service
public class PlanServiceImpl implements PlanService{

	private static final Logger logger = LoggerFactory.getLogger(PlanServiceImpl.class);
	
	@Autowired
	private PlanMapper planMapper;
	
	@Override
	public ArrayList<HashMap<String,Object>> getDataSource(HashMap<String,Object> param){
		return planMapper.getDataSource(param);
	}
	
	@Override
	public int insertPlan(HashMap<String,Object> param){
		try{
			planMapper.insertPlan(param);
			return 0;
		}catch(Exception ex){
			logger.error(ex.getMessage());
			return -1;
		}
	}
	
	@Override
	public ArrayList<HashMap<String,Object>> getLabelName(HashMap<String,Object> param)
	{
		return planMapper.getLabelName(param);
	}	
	
	@Override
	public ArrayList<HashMap<String,Object>> getPlanList(HashMap<String,Object> param)
	{
		int count = planMapper.getPlanListCount(param);
		if(count == 0){
			return null;
		}else{
			param.put("pageCount", count);
			return planMapper.getPlanList(param);
		}
	}	
	
	@Override
	public int updatePlan(HashMap<String,Object> param){
		try{
			planMapper.updatePlan(param);
			return 0;
		}catch(Exception ex){
			logger.error(ex.getMessage());
			return -1;
		}
	}
	
	@Override
	public int deletePlan(HashMap<String,Object> param){
		try{
			planMapper.deletePlan(param);
			return 0;
		}catch(Exception ex){
			logger.error(ex.getMessage());
			return -1;
		}
	}
	
	@Override
	public int startOrStopPlan(HashMap<String,Object> param){
		try{
			planMapper.startOrStopPlan(param);
			return 0;
		}catch(Exception ex){
			logger.error(ex.getMessage());
			return -1;
		}
	}
	
	@Override
	public HashMap<String,Object> checkPlanName(String name){
		return planMapper.checkPlanName(name);
	}
	
	@Override
	public ArrayList<HashMap<String,Object>> CheckPlanTitle(HashMap<String,Object> param)
	{
		return planMapper.CheckPlanTitle(param);
	}	
}
